﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Stat_ArticlePublic : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindInit();
        }
    }

    private void BindInit()
    {
        txts.Text = (Request["st"] != null && Request["st"].ToString().Length > 0 ? Server.UrlDecode(Request["st"].ToString()) : "");
        txte.Text = (Request["et"] != null && Request["et"].ToString().Length > 0 ? Server.UrlDecode(Request["et"].ToString()) : "");


        Bind(Request["page"] == null || Request["page"].ToString() == "" ? 1 : Convert.ToInt32(Request["page"]));
    }

    private void Bind(int page)
    {
        Usas.BLL.Cms.AspPager ap = new Usas.BLL.Cms.AspPager();

        string usasdb = System.Configuration.ConfigurationManager.AppSettings["ConnectionStringUsas"].ToString();

        Usas.BLL.Cms.StatOperate so = new Usas.BLL.Cms.StatOperate();

        string st = (txts.Text != "" ? " and ModfiyTime >='" + txts.Text + "'" : "");
        string et = (txte.Text != "" ? " and ModfiyTime <='" + txte.Text + "'" : "");

        //usasdb
        DataSet dt = so.ArticleStat(st + et, usasdb);
        RptChatList.DataSource = dt;
        RptChatList.DataBind();

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string st = "&st=" + (txts.Text != "" ? Server.UrlEncode(txts.Text) : "");
        string et = "&et=" + (txte.Text != "" ? Server.UrlEncode(txte.Text) : "");
        Response.Redirect("ArticlePublic.aspx?" + st + et);
    }
    protected void RptChatList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataRowView drv = (DataRowView)e.Item.DataItem;
            Literal li = (Literal)e.Item.FindControl("lit_count");
            double ct = Convert.ToDouble(drv["ct"]) / Convert.ToDouble(drv["ok"]) * 100;
            li.Text = "<div style='background-color:red;height:10px; width:" + ct + "%'></div>";
        }
    }
}
